/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

import React from "react";
import { Button, Form, DatePicker, Input, Select } from "antd";
import moment from "moment/moment";
import KbBrands from "@/components/Select/Brands";
import KbYzs from "@/components/Select/Yzs";

const { RangePicker } = DatePicker;
const { Option } = Select;
const { Item: FormItem } = Form;

const disabledDate = current => {
  return (
    current &&
    current >
      moment()
        .endOf("day")
        .subtract(0, "days")
  );
};
const defaultSelectDate = {
  startDate: moment()
    .subtract(1, "month")
    .startOf("month"),
  endDate: moment()
    .subtract(1, "month")
    .endOf("month"),
};

const Search = props => {
  const {
    parentHandle: { reset, submit },
    form: { getFieldDecorator },
  } = props;
  return (
    <Form layout="inline" style={{ marginBottom: 15 }}>
      <FormItem>
        {getFieldDecorator("time", {
          initialValue: [defaultSelectDate.startDate, defaultSelectDate.endDate],
        })(
          <RangePicker
            style={{ width: 400 }}
            showTime={{ format: "HH:mm:ss" }}
            format="YYYY-MM-DD HH:mm:ss"
            disabledDate={disabledDate}
            placeholder={["请输入开始时间", "请输入结束时间"]}
          />
        )}
      </FormItem>
      <FormItem>
        {getFieldDecorator("brand", {})(
          <KbBrands style={{ width: 120 }} requestType="source/getKopBrand" />
        )}
      </FormItem>
      <FormItem>
        {getFieldDecorator("inn_name", {})(
          <KbYzs style={{ width: 140 }} requestType="order_calculate/getSubDaksList" />
        )}
      </FormItem>
      <FormItem>
        {getFieldDecorator("is_compute", {
          initialValue: "",
        })(
          <Select style={{ width: 120 }}>
            <Option value="">全部</Option>
            <Option value="1">已计算</Option>
            <Option value="2">未计算</Option>
          </Select>
        )}
      </FormItem>
      <FormItem>
        <FormItem>
          {getFieldDecorator("waybill_no", {})(
            <Input placeholder="请输入运单号" style={{ width: 200 }} />
          )}
        </FormItem>
      </FormItem>
      <FormItem>
        <Button type="primary" icon="search" onClick={submit}>
          查询
        </Button>
      </FormItem>
      <FormItem>
        <Button onClick={reset}>重置</Button>
      </FormItem>
    </Form>
  );
};

export default Search;
